import { Component, _decorator, Node } from "cc";
import { RootSystem } from "db://assets/script/game/demo/ecs/system/RootSystem";
import { ecs } from "db://oops-framework/libs/ecs/ECS";
import { MoveComponent } from "db://assets/script/game/demo/ecs/comp/MoveComponent";
import { TransformComponent } from "db://assets/script/game/demo/ecs/comp/TransformComponent";
import { NodeComponent } from "db://assets/script/game/demo/ecs/comp/NodeComponent";
import { AvatarEntity } from "db://assets/script/game/demo/ecs/entity/AvatarEntity";

const {ccclass} = _decorator;

@ccclass("GameControllerBehaviour")
export class GameControllerBehaviour extends Component {

    rootSystem: RootSystem | null = null;

    onLoad() {
        this.rootSystem = new RootSystem();
        this.rootSystem.init();
    }

    createAvatar(node: Node) {
        let entity = ecs.getSingleton(NodeComponent);
        entity.val = node;
    }

    update(dt: number) {
        this.rootSystem?.execute(dt);
    }
}